package com.yc.booktable.biz;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yc.booktable.entity.Food;
import com.yc.booktable.service.impl.FoodServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class FoodBiz {
    @Resource
    private FoodServiceImpl foodService;


    public void savef(Food food) throws BizException{
       /* QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("fid",food.getFid());*/

        /*List<Food> foodList = foodService.findf(food.getFid());*/
        if(food.getFname().trim().isEmpty()){
            throw new BizException("名称不能为空!");
        }
        if(food.getFtype().trim().isEmpty()){
            throw new BizException("类型不能为空!");
        }
        if(food.getPrice()==null){
            throw new BizException("价格不能为空!");
        }
       /* for(Food fid : foodList){
            if(fid.getFid()==food.getFid()){
                throw new BizException("该菜品已存在!");
            }
        }*/

        foodService.saveOrUpdate(food);
    }
    }


